home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Digests / CSMP Digest / volume 2 / csmp-v2-018.txt < prev    next >
Encoding:
Text File  |  1995-06-30  |  40.9 KB  |  1,016 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Thu, 11 Mar 93       Volume 2 : Issue 18
  2.  
  3. Today's Topics:
  4.  
  5.     help calling assembly from C
  6.     Calling external code resources - how?
  7.     What's in an unloaded resource handle?
  8.     SystemClick neccesary in Sys. 7?
  9.     Mac Plus Driver Unit Table
  10.     Hints on getting a spinning cursors..
  11.     Game Animation
  12.  
  13.  
  14.  
  15. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  16.  
  17. The digest is a collection of article threads from the usenet newsgroup
  18. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  19. regularly and want an archive of the discussions.  If you don't know what a
  20. newsgroup is, you probably don't have access to it.  Ask your systems
  21. administrator(s) for details.  If you don't have access to news, you can
  22. post articles to any newsgroup by mailing your article to
  23.     newsgroup@cs.utexas.edu
  24. So, to post an article to comp.sys.mac.programmer, mail your article to
  25.     comp-sys-mac-programmer@cs.utexas.edu
  26. Note the '-' instead of '.' in the newsgroup name.  Be sure to ask that
  27. replies be emailed to you instead of posted to the group, and give your
  28. email address.
  29.  
  30. Each issue of the digest contains one or more sets of articles (called
  31. threads), with each set corresponding to a 'discussion' of a particular
  32. subject.  The articles are not edited; all articles included in this digest
  33. are in their original posted form (as received by our news server at
  34. cs.uoregon.edu).  Article threads are not added to the digest until the last
  35. article added to the thread is at least one month old (this is to ensure that
  36. the thread is dead before adding it to the digest).  Article threads that
  37. consist of only one message are generally not included in the digest.
  38.  
  39. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  40. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  41. file /pub/mac/csmp-digest/README before downloading any files.  The most
  42. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  43. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  44. archive has a mail server; send a message with the text '$MACarch help' (no
  45. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  46.  
  47. The digest is also available via email.  Just send a note saying that you
  48. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  49. automatically receive each new issue as it is created.  Sorry, back issues
  50. are not available through the mailing list.
  51.  
  52. Send administrative mail to mkelly@cs.uoregon.edu.
  53.  
  54.  
  55. -------------------------------------------------------
  56.  
  57. From: eapg070@orion.oac.uci.edu (Caroll Elke Pohl)
  58. Subject: help calling assembly from C
  59. Organization: University of California, Irvine
  60. Date: 23 Jan 93 19:13:05 GMT
  61.  
  62. greetings mac programmers!
  63.  
  64. i wonder if someone out there can assist me with a small problem.
  65. i'm using MPW (3.2) and want to call an assembly language subroutine
  66. i wrote from a C program _however_ i want to pass the parameters in
  67. A0 and A1 instead of using the stack (much like certain memory
  68. manager traps). how can i get the C compiler to recognize this fact?
  69.  
  70. on a related matter, can anyone recommend a good book on writing
  71. assembly programs on the mac.
  72. a perfect book would include:
  73. 1) writing MC68000 code in general
  74. 2) using mac traps, pascal and C stack frames and the like
  75. 3) using the MPW assembler. things like:
  76.    a) special syntax
  77.    b) all the assembler directives and keywords
  78.    c) how to do more complicated things like segmenting
  79.         and external routines.
  80.  
  81. any recommendations would be much appreciated.
  82. please e-mail.
  83.  
  84. - -caroll
  85.  
  86. *********************************************
  87.                       ) """ (
  88.                        (Q Q)
  89.    Don't spook        (  |  )
  90.     the horse!         \ A /
  91.                        (___)
  92. *********************************************
  93.  
  94. +++++++++++++++++++++++++++
  95.  
  96. From: keith@taligent.com (Keith Rollin)
  97. Organization: Taligent
  98. Date: Mon, 25 Jan 1993 01:34:42 GMT
  99.  
  100. In article <2B6198C1.22487@news.service.uci.edu>, eapg070@orion.oac.uci.edu
  101. (Caroll Elke Pohl) wrote:
  102. > i wonder if sunction(char *data,void *myWackyFunctionPtr) = 0x4E91;
  103.  
  104. (0x4E91 is the hex opcode for a JSR (A1)).  You can call this like so:
  105.  
  106. result = CallMyWackyFunction(data,MyWackyFunction);
  107.  
  108. By passing a pointer to the routine you wish to call, this avoids the
  109. problem that the hex inline can't call the function itself because
  110. it can't contain symbols that need to be linked.
  111.  
  112. Hope all this helps;
  113. Tim Dierks
  114. MacDTS, but I speak for myself
  115.  
  116. ---------------------------
  117.  
  118. From: jochen@blanc.north.de (Jochen Meyer)
  119. Subject: Calling external code resources - how?
  120. Date: 23 Jan 93 11:10:15 GMT
  121. Organization: Jochen & Son
  122.  
  123. Hello, folks!
  124.  
  125. I am currently writing a program that I want to be extensible. The
  126. most common way of handling extensibility seems to be using external
  127. code resources, like in Canvas or BBEdit.
  128.  
  129. Where can I find information on how to do this? The Segment Manager
  130. chapter of IM gives no clues on this. Anyone has got some sample code
  131. on this?
  132.  
  133. Thanks
  134.     Jochen
  135.  
  136.  
  137.  
  138.  
  139. - -------------------------------------------------------------
  140. | Jochen Meyer         |  Internet: jochen@blanc.north.de   |
  141. | Sandfurter Weg 11a   |  phone: (+49) -441 / 50 85 47      |
  142. | D-2900 Oldenburg     |------------------------------------|
  143. |----------------------|"Features are well-documented bugs."|
  144.  
  145. +++++++++++++++++++++++++++
  146.  
  147. Organization: Royal Institute of Technology, Stockholm, Sweden
  148. Date: Mon, 25 Jan 1993 00:52:16 GMT
  149.  
  150. In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
  151.  
  152. >Where can I find information on how to do this? The Segment Manager
  153. >chapter of IM gives no clues on this. Anyone has got some sample code
  154. >on this?
  155.  
  156. Your extensions can't get at your globals, however,
  157. you're not lost.
  158.  
  159. Define an interface for the extensions, consisting of ONE
  160. function that takes a lot of interesting parameters,
  161. like a handle to some data and a command, and a handle to
  162. put retusn data in, and returns an err code.
  163.  
  164. The just load in the resource, lock it, and call the dereferenced
  165. resource as a function pointers with the right arguments.
  166.  
  167. Something like:
  168.  
  169. typedef short ( * myFuncType ) ( short code , Handle dataIn , Handle dataOut ) ;
  170.  
  171. Code resources have a main with the same arguments, and
  172. you call 'em like:
  173.  
  174.     Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
  175.     HLockHi ( h ) ;
  176.     result = ( * h ) ( theCode , theInData , theOutData ) ;
  177.     ReleaseResource ( h ) ;
  178.  
  179. Cheers,
  180.  
  181.                         / h+
  182. - -- 
  183.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  184.  
  185.    There's no sex act that can't be made better with Yell-O.
  186.  
  187. +++++++++++++++++++++++++++
  188.  
  189. From: keith@taligent.com (Keith Rollin)
  190. Organization: Taligent
  191. Date: Mon, 25 Jan 1993 01:59:02 GMT
  192.  
  193. In article <01050014.odph61@blanc.north.de>, jochen@blanc.north.de (Jochen
  194. Meyer) wrote:
  195. > I am currently writing a program that I want to be extensible. The
  196. > most common way of handling extensibility seems to be using external
  197. > code resources, like in Canvas or BBEdit.
  198. > Where can I find information on how to do this? The Segment Manager
  199. > chapter of IM gives no clues on this. Anyone has got some sample code
  200. > on this?
  201.  
  202. If you have Technote #256, read it. If you don't, log onto ftp.apple.com,
  203. go to /dts/mac/tn/patforms.tools and download the file called
  204. stand-alone-code.hqx. It will tell you just what you want.
  205.  
  206. Just to whet your appetite, here's some code that I use to call CDEF's
  207. directly:
  208.  
  209.  
  210. typedef pascal long (*CDEFProc)(short varCode, ControlHandle theControl,
  211.                                     short msg, long param);
  212.  
  213. long CallCDEF(ControlHandle theControl, short msg, long param)
  214. {
  215.     CDEFProc*    defProcHandle;
  216.     GrafPtr        oldPort;
  217.     char        oldState;
  218.     long        result;
  219.             
  220.     defProcHandle = (CDEFProc*) StripAddress((**theControl).contrlDefProc);
  221.  
  222.     if (defProcHandle != nil) {
  223.  
  224.         if (*defProcHandle == nil)  {
  225.             LoadResource((Handle) defProcHandle);
  226.         }
  227.  
  228.         if (*defProcHandle != nil) {
  229.         
  230.             GetPort(&oldPort);
  231.             SetPort((**theControl).contrlOwner);
  232.             
  233.             oldState = HGetState((Handle) defProcHandle);
  234.             HLock((Handle) defProcHandle);
  235.             
  236.             result = (*defProcHandle)(GetCVariant(theControl), theControl, msg,
  237. param);
  238.                                         
  239.             HSetState((Handle) defProcHandle, oldState);
  240.             SetPort(oldPort);
  241.             
  242.             return result;
  243.         }
  244.     }
  245.  
  246.     SysError(dsCDEFNotFound);
  247. }
  248.  
  249.  
  250. - -----
  251. Keith Rollin
  252. Phantom Programmer
  253. Taligent, Inc.
  254.  
  255. +++++++++++++++++++++++++++
  256.  
  257. From: lari@cs.unc.edu (Humayun Lari)
  258. Date: 25 Jan 1993 12:10:32 -0500
  259. Organization: The University of North Carolina at Chapel Hill
  260.  
  261. tte) writes:
  262. [deleted]
  263. >you call 'em like:
  264. >
  265. >    Handle h = GetResource ( 'Xtns' , 128 ) ; /* Whatever */
  266. >    HLockHi ( h ) ;
  267. >    result = ( * h ) ( theCode , theInData , theOutData ) ;
  268. [rest deleted]
  269.  
  270. It's a good idea to StripAddress the pointer first, say:
  271.         funcPtr = StripAddress(*h);
  272.         result = funcPtr(theCode, theInData, theOutData);
  273.  
  274. This is really only necessary if the code resource will call SwapMMUMode,
  275. but it's better to be safe...
  276.  
  277. Humayun Lari
  278. (lari@cs.unc.edu)
  279.  
  280. +++++++++++++++++++++++++++
  281.  
  282. From: time@ice.com (Tim Endres)
  283. Date: Mon, 25 Jan 93 15:59:44 EST
  284. Organization: ICE Engineering, Inc.
  285.  
  286.  
  287. tte) writes:
  288. > >Where can I find information on how to do this? The Segment Manager
  289. > >chapter of IM gives no clues on this. Anyone has got some sample code
  290. > >on this?
  291. > Your extensions can't get at your globals, however,
  292. > you're not lost.
  293.  
  294. uAccess extensions can get at the globals of uAccess. These globals
  295. have been placed inside of a large data structure inside of uAccess
  296. and uAccess hands a pointer to this structure to the extension. The
  297. globals in this data structure are only those that it is felt the
  298. extension would need to access, and are "stable" enough to be locked
  299. down to a documented data structure. However, it does make for some
  300. very powerful possibilities.
  301.  
  302.  
  303. tim endres - time@ice.com  (UUCP: heifetz!tbomb!time)
  304.  
  305. USENET - a slow moving self parody... ph
  306.  
  307. +++++++++++++++++++++++++++
  308.  
  309. From: peter@cujo.curtin.edu.au (Peter N Lewis)
  310. Organization: NCRPDA, Curtin University
  311. Date: Tue, 26 Jan 1993 03:10:29 GMT
  312.  
  313. In article <1993Jan25.005216.12749@kth.se>, d88-jwa@dront.nada.kth.se (Jon
  314. Wtte) wrote:
  315. > In <01050014.odph61@blanc.north.de> jochen@blanc.north.de (Jochen Meyer) writes:
  316. > >Where can I find information on how to do this? The Segment Manager
  317. > >chapter of IM gives no clues on this. Anyone has got some sample code
  318. > >on this?
  319.  
  320. > Define an interface for the extensions, consisting of ONE
  321. > function that takes a lot of interesting parameters,
  322. > like a handle to some data and a command, and a handle to
  323. > put retusn data in, and returns an err code.
  324. > The just load in the resource, lock it, and call the dereferenced
  325. > resource as a function pointers with the right arguments.
  326.  
  327. If you want other people to be able to write externals in Pascal, give the
  328. function a Pascal interface.
  329.  
  330. Another good idea is to pass a single param block containg all the
  331. parmaeters, with a version parameter at the front, so if you decide to add
  332. more parameters later, you don't need to rewrite all the externals, you
  333. just bump the version number, and add the new parameters to the end.  An
  334. OSErr is often a good return result.
  335.  
  336. In Pascal:
  337.  
  338. type MyExternalParamBlock = record
  339.     version:longInt;
  340.     { other stuff }
  341.   end;
  342. function External(var pb:MyExternalParamBlock): OSErr;
  343.  
  344. [
  345. In C, something like this I think
  346. OSErr External(MyExternalParamBlock *pb)
  347. ]
  348.  
  349. Call it something like this:
  350.  
  351. function CallExternal(var pb:MyExternalParamBlock; proc:Ptr):OSErr;
  352. inline $205F, $4E90;
  353.  
  354. var h:handle;
  355.  
  356. h:=GetResource('Xtns',128);
  357. HLockHi(h);
  358. oe:=CallExternal(pb,h^);
  359. ReleaseResource(h)
  360.  
  361. I did something akin to this in the external tokens for Finger, the source
  362. of which should be on sumex or umich, as well as
  363. redback.cs.uwa.edu.au:/others/peterlewis.
  364.  
  365. Have fun,
  366.    Peter.
  367.  
  368. _______________________________________________________________________
  369. Peter N Lewis <peter@cujo.curtin.edu.au>             Ph: +61 9 368 2055
  370.  
  371. +++++++++++++++++++++++++++
  372.  
  373. From: Dave_Burnett@bmug.org
  374. Organization: BMUG, Inc.
  375. Date: Tue, 26 Jan 1993 10:46:54 PST
  376.  
  377. In article <1993Jan25.005216.12749@kth.se> (comp.sys.mac.programmer),
  378. d88-jwa@dront.nada.kth.se (Jon W%tte) writes:
  379. > >Where can I find information on how to do this? The Segment Manager
  380. > >chapter of IM gives no clues on this. Anyone has got some sample code
  381. > >on this?
  382.  
  383. In develop 10 there was an application with source that implemented plug-ins. 
  384. However, the implementation required that plug-ins be pasted into the app's
  385. resource fork instead of reading it from a "plug-ins folder."
  386.  
  387. **** From Planet BMUG, the FirstClass BBS of BMUG.  The message contained in
  388. **** this posting does not in any way reflect BMUG's official views.
  389.  
  390.  
  391. ---------------------------
  392.  
  393. From: thomas@camino.mic.cl (Thomas Fruin)
  394. Subject: What's in an unloaded resource handle?
  395. Organization: El Camino
  396. Date: Mon, 01 Feb 1993 23:28:58 CST
  397.  
  398. I'm doing some stuff with resources without loading them, and was
  399. wondering what's in an unloaded resource handle. For example, suppose
  400. I do (in C++)
  401.  
  402.   Handle resHndl;
  403.   SetResLoad( FALSE );
  404.   Handle resHndl = GetResource( myType, myID );
  405.   SetResLoad( TRUE );
  406.  
  407. Is resHndl now a Memory Manager handle? The Resource Manager chapter
  408. of Inside Macintosh tells me I can call routines such as GetResInfo
  409. with this Handle, but what happens if I call ReleaseResource or
  410. RmveResource? What happens if I dereference the "handle"?
  411.  
  412. Maybe somebody can give some background on what's technically in one
  413. of those handle's?
  414.  
  415. Thanks,
  416.  
  417. - -- Thomas Fruin
  418.  
  419.    GroupWare Ltda.
  420.    Niebla, Chile
  421.  
  422.    thomas@camino.mic.cl
  423.  
  424.  
  425. +++++++++++++++++++++++++++
  426.  
  427. Organization: Royal Institute of Technology, Stockholm, Sweden
  428. Date: Wed, 3 Feb 1993 20:07:09 GMT
  429.  
  430. In <0105013E.p3dn57@camino.mic.cl> thomas@camino.mic.cl (Thomas Fruin) writes:
  431.  
  432. >  SetResLoad( FALSE );
  433. >  Handle resHndl = GetResource( myType, myID );
  434. >  SetResLoad( TRUE );
  435.  
  436. >Is resHndl now a Memory Manager handle? The Resource Manager chapter
  437. >of Inside Macintosh tells me I can call routines such as GetResInfo
  438. >with this Handle, but what happens if I call ReleaseResource or
  439. >RmveResource? What happens if I dereference the "handle"?
  440.  
  441. The handle is still exactly the same as if you had
  442. loaded a resource, except the master pointer it points
  443. to is NULL (i.e. DON'T DEREFERENCE IT)
  444.  
  445. The effect is the same as if the resource had been read
  446. and then purged (i.e. marked purgable and unlocked) All
  447. information about the resource is still intact; you can
  448. get the actual data by calling LoadResource. Note that
  449. when the resource is marked as purgeable (and is not
  450. locked) the same thing can happen.
  451.  
  452. Cheers,
  453.  
  454.                         / h+
  455. - -- 
  456.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  457.  
  458.   "Practice random kindness, and senseless acts of beauty."
  459.  
  460. +++++++++++++++++++++++++++
  461.  
  462. From: kurisuto@chopin.udel.edu (Sean J. Crist)
  463. Organization: University of Delaware
  464. Date: Wed, 3 Feb 1993 21:32:15 GMT
  465.  
  466. tte) writes:
  467. >In <0105013E.p3dn57@camino.mic.cl> thomas@camino.mic.cl (Thomas Fruin) writes:
  468.  
  469. >>  SetResLoad( FALSE );
  470. >>  Handle resHndl = GetResource( myType, myID );
  471. >>  SetResLoad( TRUE );
  472.  
  473. >>Is resHndl now a Memory Manager handle? The Resource Manager chapter
  474. >>of Inside Macintosh tells me I can call routines such as GetResInfo
  475. >>with this Handle, but what happens if I call ReleaseResource or
  476. >>RmveResource? What happens if I dereference the "handle"?
  477.  
  478. >The handle is still exactly the same as if you had
  479. >loaded a resource, except the master pointer it points
  480. >to is NULL (i.e. DON'T DEREFERENCE IT)
  481.  
  482. If I'm not mistaken, it will not always be null.  If the resource already
  483. happens to be in memory, I believe that GetResource returns a handle to it
  484. whether resource loading is turned on or off.  If you wanted to do
  485. something with this handle you'd have to test it to see whether it were
  486. actually null or not.
  487.  
  488. - --Kurisuto
  489.  
  490.  
  491. ---------------------------
  492.  
  493. Subject: SystemClick neccesary in Sys. 7?
  494. From: seth@physc1.byu.edu
  495. Date: 4 Feb 93 19:43:33 -0700
  496. Organization: Brigham Young University
  497.  
  498. Hi folks. 
  499. In these days of System 7, is it necessary to use the SystemClick function in
  500. our event loops anymore? I have read that DA's don't work like they used to, 
  501. and are more like real apps now. If I write a sys 7 only app, is it really
  502. necessary to include a call to SystemClick? What other "system windows" are
  503. there that would require this? The THINK Reference 1.0 doesn't answer my 
  504. question. 
  505.  
  506. Seth Leigh
  507. BYU Physics Dept.
  508.  
  509. PS: I sent off my upgrade form and check about two weeks ago. How long does it
  510. take for them to get me my ugrade to THINK Reference 2.0? I just love the 
  511. heck out of 1.0, I'm sure I will adore 2.0 to no end...
  512.  
  513.  
  514. +++++++++++++++++++++++++++
  515.  
  516. Organization: Royal Institute of Technology, Stockholm, Sweden
  517. Date: Fri, 5 Feb 1993 09:13:11 GMT
  518.  
  519. In <1993Feb4.194334.389@physc1.byu.edu> seth@physc1.byu.edu writes:
  520.  
  521. >In these days of System 7, is it necessary to use the SystemClick function in
  522. >our event loops anymore? I have read that DA's don't work like they used to, 
  523. >and are more like real apps now. If I write a sys 7 only app, is it really
  524.  
  525. I think SystemClick is used for the switching between application
  526. clicking, and switch-to-finder-in-desktop clicks.
  527.  
  528. I e all windows that aren't your are "System" windows (to your
  529. app)
  530.  
  531. Cheers,
  532.  
  533.                         / h+
  534. - -- 
  535.  -- Jon W{tte, h+@nada.kth.se, Mac Hacker Deluxe --
  536.  Engineering: "How will this work?" Science: "Why will this work?" Management:
  537.  "When will this work?"  Liberal Arts: "Do you want fries with that?"
  538.                      -- Jesse N. Schell
  539.  
  540. ---------------------------
  541.  
  542. From: csuley@cs.cornell.edu (Christopher Suley)
  543. Subject: Mac Plus Driver Unit Table
  544. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  545. Date: Thu, 4 Feb 1993 02:38:44 GMT
  546.  
  547. csuley@cs.cornell.edu (Christopher Suley) writes:
  548. >How many entries are there in the driver unit table on a Plus?
  549. >Is it 48 as indicated in Inside Mac IV, or has it expanded to
  550. >64 as indicated in Inside Mac V?
  551.  
  552. Well? No one knows? Could someone with a Plus break into MacsBug and
  553. type 'du' (dm utablebase unittable) and tell me what the biggest number
  554. on the driver table is?  If I had a Plus anywhere around me, I'd do it
  555. myself but I don't so I can't.
  556.  
  557. - -- 
  558. *plonk*
  559. This post comes pre-*plonk*ed for your convenience.
  560.  
  561. +++++++++++++++++++++++++++
  562.  
  563. From: resnick@cogsci.uiuc.edu (Pete Resnick)
  564. Date: Thu, 4 Feb 1993 20:36:56 GMT
  565. Organization: University of Illinois at Urbana
  566.  
  567. csuley@cs.cornell.edu (Christopher Suley) writes:
  568.  
  569. >csuley@cs.cornell.edu (Christopher Suley) writes:
  570. >>How many entries are there in the driver unit table on a Plus?
  571. >>Is it 48 as indicated in Inside Mac IV, or has it expanded to
  572. >>64 as indicated in Inside Mac V?
  573.  
  574. >Well? No one knows? Could someone with a Plus break into MacsBug and
  575. >type 'du' (dm utablebase unittable) and tell me what the biggest number
  576. >on the driver table is?  If I had a Plus anywhere around me, I'd do it
  577. >myself but I don't so I can't.
  578.  
  579. Checking the driver table on a Plus in Macsbug won't do it since many
  580. INITs expand the Unit Table. As far as I know, the Mac Plus still has
  581. only 48 entries by default. There is a method for increasing that
  582. number to as much as 128. I have code examples which explain this very
  583. nicely and are available by anonymous FTP from several places and are
  584. on Compuserve. The last release version was "driver 2.1.8", but please
  585. look for "driver 2.1.9" which I am about to send out today or
  586. tomorrow; there were some problems with 2.1.8 which I have since
  587. fixed.
  588.  
  589. pr
  590. - -- 
  591. Pete Resnick             (...so what is a mojo, and why would one be rising?)
  592. Graduate assistant - Philosophy Department, Gregory Hall, UIUC
  593. System manager - Cognitive Science Group, Beckman Institute, UIUC
  594. Internet: resnick@cogsci.uiuc.edu
  595.  
  596. +++++++++++++++++++++++++++
  597.  
  598. From: maarten@fwi.uva.nl (Maarten Carels)
  599. Organization: FWI, University of Amsterdam
  600. Date: Fri, 5 Feb 1993 09:26:48 GMT
  601.  
  602. resnick@cogsci.uiuc.edu (Pete Resnick) writes:
  603. >csuley@cs.cornell.edu (Christopher Suley) writes:
  604.  
  605. >>csuley@cs.cornell.edu (Christopher Suley) writes:
  606. >>>How many entries are there in the driver unit table on a Plus?
  607. >>>Is it 48 as indicated in Inside Mac IV, or has it expanded to
  608. >>>64 as indicated in Inside Mac V?
  609. >Checking the driver table on a Plus in Macsbug won't do it since many
  610. >INITs expand the Unit Table. As far as I know, the Mac Plus still has
  611. >only 48 entries by default.
  612. There is no need to hardcode any such number. There exists a low mem global,
  613. it's called UnitNtry, a word at 0x1d2, it contains the number of entries in
  614. the Unit table.
  615.  
  616. Note that the size of the block the unittable is in may be other than 4 times
  617. this value. I've seen the unittable block as large as 96 entries, with UnitNtry
  618. only being 48. If you need more entries, compare UnitNtry against
  619. GetPointerSize (UTableBase).
  620. You can set UnitNtry to GetPointerSize (UTableBase) / sizeof (long).
  621.  
  622. - --maarten
  623. - -- 
  624. In real life:    Maarten Carels
  625.         Computer Science Department
  626.         University of Amsterdam
  627. email:        maarten@fwi.uva.nl
  628.  
  629. ---------------------------
  630.  
  631. From: walrath@faw.uni-ulm.de (Wayne K. Walrath)
  632. Subject: Hints on getting a spinning cursors..
  633. Organization: FAW (Research Institute For Applied Knowledge Processing, Ulm, Germany)
  634. Date: Thu, 4 Feb 1993 13:06:33 GMT
  635.  
  636. Thanks to Jon and Peter (and others) for the sample code and 
  637. suggestions on how to get a directory's contents. 
  638.  
  639. >As Jon said, learn to love the PBGetCatInfo call, its very important (less
  640. >important than learning the difference between vrn's and working directory
  641. >numbers and how dirIDs fit in, but still quite important).
  642.  
  643. After two long evenings in the debugger everything is working beautifully,
  644. and I HAVE learned to love PBGetCatInfo.... But I did have a terrible time
  645. with the data structure for this call (CInfoPBRec or something similiar); 
  646. being not such an accomplished C programmer, I didn't fully understand how
  647. to work with Unions, and kept getting a member not found error message. In 
  648. Think C the record is defined as having a ParamBlockHeader, then the union
  649. of a hFileInfo and dirInfo structures.
  650.  
  651. I need to get my cursor to spin now, and I presume that I can define a 
  652. number of different cursors myself, then call a SpinCursor routine which
  653. cycles through all them.  Is this basically correct?  If I just want to spin
  654. the watch cursor, how is that done? 
  655.  
  656. What is the best way to deal with these resources?  Load each cursor from
  657. the resource file right before the call to SetCursor, or should I attempt
  658. to keep them all locked in memory.
  659.  
  660. Suggestions appreciated.
  661.  
  662. - -wayne
  663.              / Wayne K. Walrath                      \
  664.             / walrath@faw.uni-ulm.de                   \
  665.             \ The Rsrch. Institute for Applied         /
  666.              \ Knowledge Processing & AI-Ulm, Germany /
  667.  
  668.  
  669. +++++++++++++++++++++++++++
  670.  
  671. From: casgrain@ERE.UMontreal.CA (Casgrain Philippe)
  672. Date: 4 Feb 93 14:43:33 GMT
  673. Organization: Universite de Montreal
  674.  
  675. In article <1993Feb4.130633.21433@wega.rz.uni-ulm.de> walrath@faw.uni-ulm.de (Wayne K. Walrath) writes:
  676. >
  677. >I need to get my cursor to spin now, and I presume that I can define a 
  678. >number of different cursors myself, then call a SpinCursor routine which
  679. >cycles through all them.  Is this basically correct?  If I just want to spin
  680. >the watch cursor, how is that done? 
  681. >
  682. >What is the best way to deal with these resources?  Load each cursor from
  683. >the resource file right before the call to SetCursor, or should I attempt
  684. >to keep them all locked in memory.
  685. >
  686. I would suggest installing the SpinCursor routine as a VBL (i.e. asynchronous)
  687. task.  This means that the cursor will spin at the same speed regardless
  688. of the current task.
  689.  
  690. It is well documented in Knaster 'n Rollin's "Mac. Programming Secrets, 2nd ed."
  691. (yeah, I know, I liked it so much that I bought the company! ;-).
  692. I have followed their advice, and created a little library that you can link
  693. to anything (Pascal, C, even Fortran!). If you want it, let me know
  694.  
  695. Philippe
  696.  
  697. - -- 
  698. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  699. Philippe Casgrain              Etudiant-Chercheur      Casgrain@ERE.UMontreal.CA
  700. Departement des Sciences Biologiques                      Universite de Montreal
  701. #define disclaimer(caught) (caught ? "I wasn't even there!" : "I didn't do it!")
  702.  
  703. +++++++++++++++++++++++++++
  704.  
  705. From: keith@taligent.com (Keith Rollin)
  706. Organization: Taligent
  707. Date: Fri, 5 Feb 1993 01:10:41 GMT
  708.  
  709. In article <1993Feb4.144333.10555@cc.umontreal.ca>,
  710. casgrain@ERE.UMontreal.CA (Casgrain Philippe) wrote:
  711. > In article <1993Feb4.130633.21433@wega.rz.uni-ulm.de> walrath@faw.uni-ulm.de (Wayne K. Walrath) writes:
  712. > >
  713. > >I need to get my cursor to spin now, and I presume that I can define a 
  714. > >number of different cursors myself, then call a SpinCursor routine which
  715. > >cycles through all them.  Is this basically correct?  If I just want to spin
  716. > >the watch cursor, how is that done? 
  717. > >
  718. > >What is the best way to deal with these resources?  Load each cursor from
  719. > >the resource file right before the call to SetCursor, or should I attempt
  720. > >to keep them all locked in memory.
  721. > >
  722. > I would suggest installing the SpinCursor routine as a VBL (i.e. asynchronous)
  723. > task.  This means that the cursor will spin at the same speed regardless
  724. > of the current task.
  725.  
  726. There was discussion on this on the net about a year ago. I think that the
  727. general consensus was that it was better to spin the cursor by calling
  728. SpinCursor from various spots within the program. That way, it conveys to
  729. the user that the process is proceeding from one stage to another (first it
  730. hits a slow algorithm, then it hits a fast one, now it's writing data to
  731. disk so the cursor has stopped spinning altogether, etc.).
  732.  
  733. I don't like the VBL approach because it gives no indication that the
  734. program has hung (important to us developers). There have been articles
  735. suggesting how to feed the VBL task tickle messages from the application so
  736. that it knows the application hasn't hung, but now your program is
  737. sprinkled with calls to TickleCursorVBL instead of SpinCursor.
  738.  
  739. > It is well documented in Knaster 'n Rollin's "Mac. Programming Secrets, 2nd ed."
  740. > (yeah, I know, I liked it so much that I bought the company! ;-).
  741.  
  742. So that's who bought all my stock!
  743.  
  744. - -----
  745. Keith Rollin
  746. Phantom Programmer
  747. Taligent, Inc.
  748.  
  749. +++++++++++++++++++++++++++
  750.  
  751. From: lari@cs.unc.edu (Humayun Lari)
  752. Date: 5 Feb 1993 10:35:40 -0500
  753. Organization: The University of North Carolina at Chapel Hill
  754.  
  755. In article <keith-040293165323@kip-50.taligent.com> keith@taligent.com (Keith Rollin) writes:
  756. >There was discussion on this on the net about a year ago. I think that the
  757. >general consensus was that it was better to spin the cursor by calling
  758. >SpinCursor from various spots within the program. That way, it conveys to
  759. >the user that the process is proceeding from one stage to another (first it
  760. >hits a slow algorithm, then it hits a fast one, now it's writing data to
  761. >disk so the cursor has stopped spinning altogether, etc.).
  762.  
  763. One problem with this method is that the speed of the spinning is dependent
  764. on the speed of the Mac. In some programs, the cursor is changed so often on
  765. fast machines that it flickers, making the program look rather unpolished.
  766. And machines are getting faster all the time.
  767.  
  768. A possible solution is to set some kind of threshold, so, for instance, the
  769. cursor's only changed if *at least* 1/10 of a second has gone by.
  770.  
  771. >I don't like the VBL approach because it gives no indication that the
  772. >program has hung (important to us developers). There have been articles
  773. >suggesting how to feed the VBL task tickle messages from the application so
  774. >that it knows the application hasn't hung, but now your program is
  775. >sprinkled with calls to TickleCursorVBL instead of SpinCursor.
  776.  
  777. IMHO, this can be better, if only because it matches the constant rate used by
  778. the spinning hands on Finder 7.x's watch cursor.
  779.  
  780. It would be nice to have a HIN on this. Does anyone know if there's an
  781. "official" way to propose a HIN topic?
  782.  
  783. Humayun Lari
  784. (lari@cs.unc.edu)
  785.  
  786. ---------------------------
  787.  
  788. From: david.wareing@insane.apana.org.au (David Wareing)
  789. Subject: Game Animation
  790. Date: Wed, 03 Feb 1993 08:30:00
  791.  
  792.  
  793. There has been some discussion in recent months about the suitability of QD to
  794.  efficiently handle fast, clean animation - of the type required for
  795.  action/arcade games.  Several people have claimed that a game such as Prince
  796.  of Persia *could* be  written with QD, others have protested this.
  797.  
  798. Can someone please clarify this.  I am in the process of writing a game.  I
  799.  need to know if it is possible to animate (say at the the POP level) with QD
  800.  or do I HAVE to start learning assembly real fast?
  801.  
  802. thanks,
  803.  
  804. David Wareing
  805. Seacliff, South Australia.
  806.  
  807.  
  808.  
  809. +++++++++++++++++++++++++++
  810.  
  811. From: zobkiw@world.std.com (Joe Zobkiw)
  812. Organization: The World Public Access UNIX, Brookline, MA
  813. Date: Fri, 5 Feb 1993 14:58:37 GMT
  814.  
  815. In article <728841576.AA00368@insane.apana.org.au> david.wareing@insane.apana.org.au (David Wareing) writes:
  816. >
  817. >There has been some discussion in recent months about the suitability of QD to
  818. > efficiently handle fast, clean animation - of the type required for
  819. > action/arcade games.  Several people have claimed that a game such as Prince
  820. > of Persia *could* be  written with QD, others have protested this.
  821. >
  822. >Can someone please clarify this.  I am in the process of writing a game.  I
  823. > need to know if it is possible to animate (say at the the POP level) with QD
  824. > or do I HAVE to start learning assembly real fast?
  825. >
  826.  
  827. No matter what anyone says...some games will do fine with QuickDraw...
  828. others need custom routines. It entirely depends on how much action
  829. you have in the game. You should probably perform some timing tests
  830. yourself to see how QuickDraw works for YOU :)
  831.  
  832.  
  833.  
  834. - -- 
  835. - -------------------------------------------------------------
  836. joe zobkiw                               zobkiw@world.std.com
  837. - -------------------------------------------------------------
  838.  
  839. +++++++++++++++++++++++++++
  840.  
  841. From: werner@dewey.soe.berkeley.edu (John Werner)
  842. Date: 5 Feb 1993 19:45:19 GMT
  843. Organization: School of Education, U.C. Berkeley
  844.  
  845. In article <C1zDLp.FCJ@world.std.com> zobkiw@world.std.com (Joe Zobkiw) writes:
  846. >
  847. >No matter what anyone says...some games will do fine with QuickDraw...
  848. >others need custom routines. It entirely depends on how much action
  849. >you have in the game. You should probably perform some timing tests
  850. >yourself to see how QuickDraw works for YOU :)
  851.  
  852. I agree.  Write it first using QuickDraw.  There's no sense in
  853. worrying about writing the game code and your own custom graphics
  854. routines at the same time; it just gives you more things to debug at
  855. once.  If it's a sprite-based game, concentrate on making your
  856. algorithm clever enough to minimize the amount of CopyBitsing that has
  857. to go on for each frame.  Some of the recent posts on "Arcade-style
  858. game animation" had some good hints that I incorporated into the
  859. simulation program I'm working on.
  860.  
  861. If you still can't get it fast enough, then it's time to start
  862. worrying about rewriting the low-level bit-blasting routines in
  863. assembler.  
  864.  
  865. This is a bit over-simplified, of course.  If your initial QuickDraw
  866. version is WAY too slow, then you might want to start doing some
  867. detailed timing tests and experiments with assembler before you get
  868. too far along.
  869. - -- 
  870. John Werner                        werner@soe.berkeley.edu
  871. UC Berkeley School of Education    (510) 596-5868 (new number)
  872.  
  873. +++++++++++++++++++++++++++
  874.  
  875. From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
  876. Date: 5 Feb 93 21:48:10 GMT
  877. Organization: The Great Beyond
  878.  
  879. In article <728841576.AA00368@insane.apana.org.au> david.wareing@insane.apana.org.au (David Wareing) writes:
  880. >
  881. >There has been some discussion in recent months about the suitability of QD to
  882. > efficiently handle fast, clean animation - of the type required for
  883. > action/arcade games.  Several people have claimed that a game such as Prince
  884. > of Persia *could* be  written with QD, others have protested this.
  885. >
  886. >Can someone please clarify this.  I am in the process of writing a game.  I
  887. > need to know if it is possible to animate (say at the the POP level) with QD
  888. > or do I HAVE to start learning assembly real fast?
  889. >
  890. >thanks,
  891. >
  892. >David Wareing
  893. >Seacliff, South Australia.
  894. >
  895.  
  896. David,
  897.  
  898.    I have been working on learning the fundamentals for writing Mac games
  899. for the past year or so, albeit not at any great pace.  I had heard that
  900. fast, smooth animation required direct-screen drawing, and believed it,
  901. but concluded that since I didn't know assembly I wouldn't be able to do it.
  902. And so I concentrated on learning about GWorlds and CopyBits and how to do
  903. the fastest graphics possible using QuickDraw.
  904.  
  905.    And it was a pain.  I won't say it would be impossible to write something
  906. like Prince of Persia using QuickDraw -- well, OK, I will -- it probably
  907. would be pretty close to impossible.  Quickdraw can be Quick -- but while
  908. I can't authoritatively say that it can't be used to write fast-action games
  909. (since I don't know how to do fast-action games with it), I do point to all
  910. the fast action games that have been written for the Mac, and none, to my
  911. knowledge, have used QuickDraw.
  912.  
  913.    So at some point I resolved that I would learn how to write directly to
  914. the screen.  And I did.  And I do.  And I wouldn't do it any other way now.
  915.  
  916.    You *don't* need to know assembly to do it, although it certainly would
  917. help.  I've developed a pretty thorough library of routines that write to the
  918. screen very quickly, handle sprites, etc.  I've still got some work to do;
  919. I'm working on a fast masking algorithm suited specifically for my types of
  920. sprites, etc., but I've been able to demonstrate that I will be able to have
  921. very fast, arcade-action graphics.  Definitely comparable with Prince of
  922. Persia and just about anything else out there.  (Now, if I only had the
  923. artistic talent..)
  924.  
  925.    And I still don't know Assembly.  However, I'm pretty good at bit
  926. manipulations and it's definitely helpful if you can think in bases other
  927. than 10.  If you want to sync your game with the monitor, then you would
  928. need to know assembly, although there's several Think C snippets floating
  929. around (that use assembly) that accomplish this task for you.  There's
  930. also handy code around that fades the monitor in and out.
  931.  
  932.    So how can you learn how to write directly to the screen?  If you go
  933. back and look at some of the comp.sys.mac.programmer/games archives,
  934. there's been threads in the past related to it.  Some very smart people
  935. have divulged some helpful pointers, like Ben Staller and Joe Holt.
  936. Also, issue 11 of Develop (Apple's programming journal) contains an
  937. article (and sample code) titled "Graphical Truffles," written by Brigham
  938. Stevens and Bill Guschwan, that contains basically all the info. you need
  939. to know to successfully write to the screen.  (For example, it tells you
  940. things to do to keep your program from breaking -- such as changing to
  941. 32-bit mode before you go messing around with the video RAM, etc.)
  942.  
  943.    Writing directly to the screen is dangerous and hard to do "right".  You
  944. have probably heard a lot of people warning not to do it, and this might
  945. have scared you away -- don't let it.  I've got three pages of source code
  946. which seem to safely implement direct-drawing on just about any system.
  947. (In 8-bit color, at least.  Monitor size doesn't matter.)  (And those three
  948. pages contain routines to draw points, fills, lines, etc., very quickly.
  949. Even scroll the screen horizontally -- not slow at all, but definitely not
  950. Sonic the Hedgehog.)
  951.  
  952.    It's a challenge, it's fun, and you get to learn a lot..  I'm starting
  953. from the ground up, trying to build my own library that's equivilent in many
  954. ways to QuickDraw, except without the speed barrier.
  955.  
  956.    So, to sum up this long message: You probably *can't* write a game like
  957. Prince of Persia with Quickdraw.  However, there's lots of games you CAN
  958. write with Quickdraw -- in which case you should definitely use Quickdraw.
  959. (For example, strategy games, games like Tetris that don't have a lot
  960. of sprites moving at once, etc.)
  961.  
  962.    But if you want to write a fast-action arcade game, don't hesitate to
  963. investigate looking into the direct-screen approach.  At the least, you'll
  964. learn something from it -- you'll have a better understanding of how graphics
  965. work on computers.  (And you might gain an appreciation for something like
  966. CopyMask!)
  967.  
  968.    It's not as hard as it's rumored to be.  It's not as imcompatible as it's
  969. rumored to be, either, although you might want to focus on working in one
  970. bit depth, such as 8-bit, at least as a starter until you get up to speed.
  971.  
  972.    There are now a collection of references available that will help you
  973. learn it -- the Graphics Truffles article being an excellent start (you
  974. can get it from ftp.apple.com), as well as some hints filed away in the
  975. archives of the internet.
  976.  
  977.    And you can keep my name around if you have questions..  I'm not an expert
  978. on this, but I'm learning quickly and know the fundamentals.
  979.  
  980.    There's also source available from cool people like Juri Munki (I hope I got
  981. his name right), such as the Arashi demo (and I hope I got THAT name right,
  982. too!  ;) that implement direct screen graphics.  However, it was done mostly
  983. in assembly and was over my head.
  984.  
  985.    But you can get away without knowing assembly.
  986.  
  987. Hope this helps!
  988.  
  989. M. Scott Smith
  990.   (mssmith@afterlife.ncsc.mil)
  991.   (umsmith@mcs.drexel.edu)
  992.  
  993. +++++++++++++++++++++++++++
  994.  
  995. From: sjked@ritvax.isc.rit.edu ("Sgt. Kleper")
  996. Organization: Rochester Institute of Technology
  997. Date: Mon, 8 Feb 1993 03:35:49 GMT
  998.  
  999. I think (that's THINK) that Pararena has an option of using Quick
  1000. Draw. I recall trying it once, and it worked about the same from
  1001. all that I could tell.
  1002.  
  1003. ---------------------------
  1004.  
  1005. End of C.S.M.P. Digest
  1006. **********************
  1007.